package com.example.mapper;

import com.example.entity.ImMessage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
* @author circle48
* @description 针对表【im_message】的数据库操作Mapper
* @createDate 2024-06-13 15:22:03
* @Entity com.example.entity.ImMessage
*/
public interface ImMessageMapper extends BaseMapper<ImMessage> {

    @Select("select from_id from im_message where to_id=#{waiterId}")
    Set<Long> getUserIdsByWaiterId(Long waiterId);
    @Select("SELECT * FROM im_message WHERE from_id = #{userId} and to_id=#{waiterId} ORDER BY create_time DESC LIMIT 1")
    ImMessage getLastMessageForUser(Long userId, Long waiterId);

}




